package com.korion.aidldemo.im;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * @author chenyinying
 * @date 2020-02-13
 */
public class Message implements Parcelable {

    public static final int START_CALL_CLIENT = 0;
    public static final int STOP_CALL_CLIENT = 1;
    public static final int CUSTOM = 2;

    public long mid;
    public int type;
    public String payload;

    protected Message(Parcel in) {
        mid = in.readLong();
        type = in.readInt();
        payload = in.readString();
    }

    public Message(int type, String payload){
        mid = System.currentTimeMillis();
        this.type = type;
        this.payload = payload;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(mid);
        dest.writeInt(type);
        dest.writeString(payload);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<Message> CREATOR = new Creator<Message>() {
        @Override
        public Message createFromParcel(Parcel in) {
            return new Message(in);
        }

        @Override
        public Message[] newArray(int size) {
            return new Message[size];
        }
    };
}
